odoo.define('sale.order', function (require) {
    "use strict";
    
    var core = require('web.core');
    var common = require('web.form_common');
    var formats = require('web.formats');
    var Dialog = require('web.Dialog');
var Model = require('web.Model');
    
    var QWeb = core.qweb;
    var _t = core._t;
    
    var FormSalesysDelivery = common.AbstractField.extend({
        render_value: function() {
            console.log("88888888888888")
            var self = this;
            var info = JSON.parse(this.get('value'));
            console.log(info)

            if (info != false){
                console.log("777777777777777777777")
                this.$el.html(QWeb.render('ShowDeliveryButton', {
                    'outstanding': info.outstanding, 
                }));
                var sale_id = info.sale_id
                console.log(sale_id)

                this.$('.outstanding_credit_assign').click(function(){
                    console.log("hahahahah1h1h1h1h1h")
                    var dialog = new Dialog(this, {
                        title: _t("物流信息"),
                        $content: QWeb.render('DeliveryPopOver',  {
                            'content': info.content, 
                            })
                    }).open();
                });

                _.each(this.$('.js_payment_info'), function(k, v){
                    console.log("hhahahahahaha")
                    var options = {
                        'content': QWeb.render('DeliveryPopOver', {
                                'content': info.content, 
                                }),
                        'html': true,
                        'placement': 'right',
                        'title': '物流信息',
                        'trigger': 'focus',
                        'delay': { "show": 0, "hide": 100 },
                    };
                    $(k).popover(options);
                });
            }
            else {
                this.$el.html('');
            }
        },
    });
    
    
    core.form_widget_registry.add('salesys_delivery', FormSalesysDelivery);
    
    });